package com.wyh.service.serviceImpl.feemanagementserviceimpl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wyh.domain.po.feemanagementpo.Refunds;
import com.wyh.mapper.feemanagementmapper.RefundssMapper;
import com.wyh.service.feemanagementservice.RefundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@PropertySource("classpath:/application.yaml")
@Service
public class RefundsServiceImpl extends ServiceImpl<RefundssMapper, Refunds> implements RefundService {

    @Autowired
    private RefundssMapper refundssMapper;
    @Override
    public List<Refunds> findAll() {
        return refundssMapper.findAll();
    }

    @Override
    public int insertRefund(Map<String, Object> refunds, int billid) {
        String pictures = (String) refunds.get("picture");
        if (pictures != null && !pictures.isEmpty()) {
            String[] pictureArray = pictures.split(",");
            refunds.put("picture", String.join(",", pictureArray));
        }
        return refundssMapper.insertRefund(refunds, billid);
    }


    @Override
    public int update(Refunds refunds) {
        return refundssMapper.update(refunds);
    }
    @Override
    public Refunds findByIdRefund(Integer id) {
        return refundssMapper.findByIdRefund(id);
    }

}
